var provinces = {};
function showCities(type, url, head, vue, cityscb) {
  console.log(url)
  console.log(head)
  var param = head;
  $.ajax({
    url: url,
    type: "POST",
    // headers:"",
    timeout: 60000,
    data: JSON.stringify(param),
    dataType: "json",
    contentType: "application/json",
    success: function (res) {
      console.log(res);
      console.log(JSON.stringify(res) + "机场列表接口");
      if (res.code == "1000") {
        //var provinces = {};
        var ks = res.content;
        var newkey = "";
        var newObj = {};
        var param = {};
        if (type == 2) {
          console.log("*******选签发国");
          for(var t in ks)
          {
              console.log(t);
              country(t);

          } 
        } else if (type == 1) {
          console.log("*******选城市");
        }
      }
      vue.$store.commit('closePop');
    },
    error: function (err) {
      vue.$store.commit('closePop');
      vue.$store.dispatch('showTx', {
        text: '网络错误'
      });
      if (err.statusText == "timeout") {
        vue.$store.dispatch('showTx', {
          text: '请求超时'
        });
        setTimeout(function () {
          window.history.go(-1);
        }, 2000);
      } else {
        vue.$store.dispatch('showTx', {
          text: '请求失败'
        });
      }
      console.log("error==>");
      console.log(err);
    }
  });
}

function load(ks) {
  for (var ps in ks) {

    var kks = pinyin.getCamelChars(ks[ps][0].substring(0, 1));
    if (kks.length == 2) {
      if (kks[0].toUpperCase() == "Z") {
        kks = "C";
      } else {
        kks = kks[0].substring(0, 1);
      }
    }
    //console.log(ks[ps][0]+"========="+pinyin.getCamelChars(ks[ps][0])+"======"+pinyin.getCamelChars(ks[ps][0].substring(0,1))+"===="+pinyin.getCamelChars(ks[ps][0].substring(0,1)).length+"==="+kks);
    switch (kks) {
      case 'A':
        //var k_city = {ks[ps][0]+":"+"["+ks[ps][0]+"]"};
        if (provinces['A'] == null) {
          provinces['A'] = {};
        }
        provinces['A'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'B':
        if (provinces['B'] == null) {
          provinces['B'] = {};
        }
        provinces['B'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'C':
        if (provinces['C'] == null) {
          provinces['C'] = {};
        }
        provinces['C'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'D':
        if (provinces['D'] == null) {
          provinces['D'] = {};
        }
        provinces['D'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'E':
        if (provinces['E'] == null) {
          provinces['E'] = {};
        }
        provinces['E'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'F':
        if (provinces['F'] == null) {
          provinces['F'] = {};
        }
        provinces['F'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'G':
        if (provinces['G'] == null) {
          provinces['G'] = {};
        }
        provinces['G'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'H':
        if (provinces['H'] == null) {
          provinces['H'] = {};
        }
        provinces['H'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'I':
        if (provinces['I'] == null) {
          provinces['I'] = {};
        }
        provinces['I'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'J':
        if (provinces['J'] == null) {
          provinces['J'] = {};
        }
        provinces['J'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'K':
        if (provinces['K'] == null) {
          provinces['K'] = {};
        }
        provinces['K'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'L':
        if (provinces['L'] == null) {
          provinces['L'] = {};
        }
        provinces['L'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'M':
        if (provinces['M'] == null) {
          provinces['M'] = {};
        }
        provinces['M'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'N':
        if (provinces['N'] == null) {
          provinces['N'] = {};
        }
        provinces['N'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'O':
        if (provinces['O'] == null) {
          provinces['O'] = {};
        }
        provinces['O'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'P':
        if (provinces['P'] == null) {
          provinces['P'] = {};
        }
        provinces['P'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'Q':
        if (provinces['Q'] == null) {
          provinces['Q'] = {};
        }
        provinces['Q'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'R':
        if (provinces['R'] == null) {
          provinces['R'] = {};
        }
        provinces['R'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'S':
        if (provinces['S'] == null) {
          provinces['S'] = {};
        }
        provinces['S'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'T':
        if (provinces['T'] == null) {
          provinces['T'] = {};
        }
        provinces['T'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'U':
        if (provinces['U'] == null) {
          provinces['U'] = {};
        }
        provinces['U'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'V':
        if (provinces['V'] == null) {
          provinces['V'] = {};
        }
        provinces['V'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'W':
        if (provinces['W'] == null) {
          provinces['W'] = {};
        }
        provinces['W'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'X':
        if (provinces['X'] == null) {
          provinces['X'] = {};
        }
        provinces['X'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'Y':
        if (provinces['Y'] == null) {
          provinces['Y'] = {};
        }
        provinces['Y'][ks[ps][0]] = [ks[ps][0]];
        break;
      case 'Z':
        if (provinces['Z'] == null) {
          provinces['Z'] = {};
        }
        provinces['Z'][ks[ps][0]] = [ks[ps][0]];
        break;
    }
  }

}
export default showCities;
